/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number[]}
 */
var twoSum = function (nums, target) {
    return findtarget(nums, target, 0)
};

//使用递归实现
let findtarget = function (nums, target, i) {
    let first_num = nums[i];
    let second_num = target - first_num;
    let j = nums.indexOf(second_num, i + 1);
    if (j > -1) {
        return [i, j];
    } else {
        if (i < nums.length) {
            findtarget(nums, target, i++);
        }
    }
}

twoSum([1, 2, 3], 3)